package tool

import (
	"context"
	"github.com/go-redis/redis/v8"
	"log"
)

func UniqueID(key string) (int64, error) {
	rdb := redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "", // 没有密码，默认值
		DB:       0,  // 默认DB 0
	})
	cmd := rdb.Incr(context.Background(), key)
	err := cmd.Err()
	if err != nil {
		log.Print()
		return 0, err
	}
	return cmd.Val(), nil
}
